package com.wc.alorithm_blue_bridge._模拟.Q7941;

import java.util.Scanner;

/**
 * @Author congege
 * @Description
 * @Date Created in 2023/12/19-22:58
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long num = sc.nextLong();
        if(num < 10){
            System.out.println(num);
            return;
        }
        while (num > 10) {
            long tmpNum = num;
            long mul = 1;
            while (tmpNum != 0) {
                if (tmpNum % 10 != 0) {
                    mul *= tmpNum % 10;
                }
                tmpNum /= 10;
            }
            System.out.println(mul);
            num = mul;
        }
    }
}
